import axiosInstance from '@/api/axiosInstance'
interface doctorListParams {
  name?: string
  staffCode?: string
  type?: number
  currentShift?: number
  status?: number
  shopId?: string
  page?: number
  pageSize?: number
  // 其他查询条件...
}

// 获取医师列表
export const getDoctorList = async (params?: doctorListParams) => {
  return axiosInstance.get('/admin/doctor', { params })
}

//获取医师列表选项
export const getDoctorOptions = async (params:{ keyword?:string,staffType?:number,isAll?:boolean}) => {
  return axiosInstance.get('/admin/doctor/options',{params})
}

// 获取医师详情
export const getDoctorDetail = async (id: number) => {
  return axiosInstance.get(`/admin/doctor/${id}`)
}

// 更新医师
export const updateDoctor = async (id: number, data: any) => {
  return axiosInstance.put(`/admin/doctor/${id}`, data)
}

// 创建医师
export const createDoctor = async (data: any) => {
  return axiosInstance.post(`/admin/doctor`, data)
}

//导出医师列表
export const exportDoctorList = async (params?: doctorListParams) => {
  return axiosInstance.get('/admin/doctor/export', { params, responseType: 'blob', timeout: 60000 })
}

//获取医师有效服务佣金列表
export const getDoctorValidServices = async (id: number) => {
  return axiosInstance.get(`/admin/doctor/${id}/service`)
}

//设置服务项目

export const setService = async (id: number, data: any) => {
  return axiosInstance.post(`/admin/doctor/${id}/service`, data)
}

//获取医师服务历史设置记录
export const getDoctorServiceHistory = async (id: number, serviceId: number, params: any) => {
  return axiosInstance.get(`/admin/doctor/${id}/service/${serviceId}/history`, { params })
}


//获取医师分成方案列表
export const getDoctorConsultPlanList = async (id: number, params: any) => {
  return axiosInstance.get(`/admin/doctor/${id}/consult-plan`, { params })
}
// 创建分成方案
export const createDoctorConsultPlan = async (doctorId: number, data: any) => {
  return axiosInstance.post(`/admin/doctor/${doctorId}/consult-plan`, data)
}
// 更新分成方案
export const updateDoctorConsultPlan = async (doctorId: number, planId: number, data: any) => {
  return axiosInstance.put(`/admin/doctor/${doctorId}/consult-plan/${planId}`, data)
}
// 删除分成方案
export const deleteDoctorConsultPlan = async (doctorId: number,planId:number) => {
  return axiosInstance.delete(`/admin/doctor/${doctorId}/consult-plan/${planId}`)
}

// 设置医师权益
export const setDoctorRight = async (doctorId: number, data: any) => {
  return axiosInstance.post(`/admin/doctor/${doctorId}/rights`, data)
}


// 创建医师驻诊形式记录
export const createDoctorShift= async (doctorId: number, data: any) => {
  return axiosInstance.post(`/admin/doctor/${doctorId}/shift`, data)
}
// 获取医师驻诊形式记录列表
export const getDoctorShiftRecordList = async (doctorId: number, params?: any) => {
  return axiosInstance.get(`/admin/doctor/${doctorId}/shift`, { params })
}
// 更新医师驻诊形式记录
export const updateDoctorShift= async (doctorId: number, recordId: number, data: any) => {
  return axiosInstance.put(`/admin/doctor/${doctorId}/shift/${recordId}`, data)
}
// 删除医师驻诊形式记录
export const deleteDoctorShift= async (doctorId: number, recordId: number) => {
  return axiosInstance.delete(`/admin/doctor/${doctorId}/shift/${recordId}`)
}

//获取医师分成规则
export const getDoctorShareRules = async (doctorId: number) => {
  return axiosInstance.get(`/admin/doctor/${doctorId}/share-rules`)
}



//批量设置医师服务项目
export const batchSetServices = async (id: number, data: any) => {
  return axiosInstance.post(`/admin/doctor/${id}/service/batch`, data)
}

export const importDoctorShare = async (data: FormData) => {
  return axiosInstance.post(`/admin/doctor/import-share`, data, { timeout: 60000 })
}

//导出医师分成
export const exportDoctorShare = async () => {
  return axiosInstance.get('/admin/doctor/export-share', { responseType: 'blob', timeout: 60000 })
}

